part of '../repository.dart';

const _kUseCaseExampleMarkdownKey = 'example';
const _kUseCaseTranslationMarkdownKey = 'translation';

class _UseCaseDto extends Equatable {
  const _UseCaseDto._internal({
    required this.exampleMarkdown,
    required this.translationMarkdown,
  });

  final String exampleMarkdown;
  final String translationMarkdown;

  @override
  List<Object?> get props {
    return [
      exampleMarkdown,
      translationMarkdown,
    ];
  }

  factory _UseCaseDto.fromJson(Map<String, dynamic> json) {
    return _UseCaseDto._internal(
      exampleMarkdown: json[_kUseCaseExampleMarkdownKey],
      translationMarkdown: json[_kUseCaseTranslationMarkdownKey],
    );
  }

  factory _UseCaseDto.fromEntity(LexicalItemUseCase useCase) {
    return _UseCaseDto._internal(
      exampleMarkdown: useCase.exampleMarkdown,
      translationMarkdown: useCase.translationMarkdown,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      _kUseCaseExampleMarkdownKey: exampleMarkdown,
      _kUseCaseTranslationMarkdownKey: translationMarkdown,
    };
  }

  LexicalItemUseCase toEntity() {
    return LexicalItemUseCase(
      exampleMarkdown: exampleMarkdown,
      translationMarkdown: translationMarkdown,
    );
  }
}
